﻿Public Class Form1



    Private TheCodeEditor As New CodeEditor With {.Parent = Me,
                                        .Height = 500,
                                        .Dock = DockStyle.Bottom}

    Private WithEvents Button1 As New Button With {.Parent = Me,
                                       .Text = "Open"}

    Private WithEvents Button2 As New Button With {.Parent = Me,
                                                  .Text = "Not Used"}


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Height = 625
        Button1.Location = New Point(15, 50)
        Button2.Location = New Point(115, 50)
        Me.StartPosition = FormStartPosition.Manual
        Me.Top = 5

    End Sub

    Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Shown
        Dim F As New ImportForm(TheCodeEditor)
        F.ShowDialog(Me)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim CodeText As String = OpenVbFile()
        TheCodeEditor.Text = CodeText
    End Sub

    'Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    '    Dim F As New ImportForm(TheCodeEditor)
    '    F.ShowDialog(Me)

    'End Sub


    Private Function OpenVbFile() As String
        Dim OFD As New OpenFileDialog
        OFD.Filter = "VB files (*.vb)|*.vb"
        OFD.ShowDialog()
        Dim Path As String = OFD.FileName
        Dim CodeText As String = ""
        If Path <> "" Then
            Using SR As New IO.StreamReader(Path)
                CodeText = SR.ReadToEnd
            End Using
        End If
        Return CodeText
    End Function

End Class
